import { listAllData, viewDetails ,exportSelfTestTable} from '@/services/qrCode';

export default {
    namespace: 'qrCode',

    state: {
        riskData: [],
        detailData: []
    },

    effects: {
        /**
            * 分页
            * @param payload
            * @param call
            * @param put
            * @returns {Generator<*, *, *>}
            */
        *listAllData({ payload }, { call, put }) {
            const response = yield call(listAllData, payload);
            return response;
        },

        *viewDetails({ payload }, { call, put }) {
            const response = yield call(viewDetails, payload);
            yield put({
                type: 'viewDetail',
                payload: response,
            });
            return response
        },

        *exportSelfTestTable({ payload }, { call, put }) {
            const response = yield call(exportSelfTestTable, payload);
            return response;
        },

    },

    reducers: {

        viewDetail(state, action) {
            return {
                ...state,
                detailData: action.payload,
            };
        },
    },
};

